﻿namespace UnityEditor
{
    using System;
    using System.Collections.Generic;
    using System.Runtime.CompilerServices;
    using UnityEngine;

    [Serializable]
    public class VCListControl
    {
        private VCListItem active;
        private Texture2D blueTex;
        private const float c_lineHeight = 16f;
        private const float c_scrollWidth = 14f;
        private Texture2D defaultIcon;
        private bool dragAcceptOnly;
        private SelectDirection dragAdjust = SelectDirection.Current;
        private int dragCount;
        private DragDelegate dragDelegate;
        private VCListItem dragTarget;
        private ExpandDelegate expandDelegate;
        private Texture2D greyTex;
        [SerializeField]
        private ListState m_listState;
        private string menuDefault;
        private string menuFolder;
        private Dictionary<string, VCListItem> pathSearch = new Dictionary<string, VCListItem>();
        private bool readOnly;
        private VCListItem root = new VCListItem();
        private static int s_uniqueIDCount = 1;
        private static Dictionary<int, VCListControl> s_uniqueIDList = new Dictionary<int, VCListControl>();
        private bool scrollVisible;
        private Dictionary<string, VCListItem> selectList = new Dictionary<string, VCListItem>();
        private VCListItem singleSelect;
        private int uniqueID = s_uniqueIDCount++;
        private List<VCListItem> visibleList = new List<VCListItem>();
        private Texture2D yellowTex;

        public VCListControl()
        {
            s_uniqueIDList.Add(this.uniqueID, this);
            this.active = this.root;
            this.Clear();
        }

        public VCListItem Add(VCListItem parent, string name, VCAsset asset)
        {
            VCListItem item = (parent == null) ? this.root : parent;
            VCListItem listItem = new VCListItem {
                Name = name,
                Asset = asset
            };
            item.Add(listItem);
            if ((listItem.Asset != null) && (listItem.Asset.path.Length > 0))
            {
                this.pathSearch[listItem.Asset.path.ToLower()] = listItem;
            }
            return listItem;
        }

        public VCListItem Add(VCListItem parent, string name, VCChangelist change)
        {
            VCListItem item = (parent == null) ? this.root : parent;
            VCListItem listItem = new VCListItem {
                Name = name
            };
            if (change == null)
            {
            }
            listItem.Change = new VCChangelist(name);
            item.Add(listItem);
            return listItem;
        }

        private void CallExpandedEvent(VCListItem item, bool remove)
        {
            if (item.Change != null)
            {
                if (item.Expanded)
                {
                    if (this.expandDelegate != null)
                    {
                        this.expandDelegate(item.Change, item);
                    }
                    this.listState.Expanded.Add(item.Change.revision);
                }
                else if (remove)
                {
                    this.listState.Expanded.Remove(item.Change.revision);
                }
            }
            for (VCListItem item2 = item.FirstChild; item2 != null; item2 = item2.Next)
            {
                this.CallExpandedEvent(item2, remove);
            }
        }

        public void Clear()
        {
            this.root.Clear();
            this.pathSearch.Clear();
            this.root.Name = "ROOT";
            this.root.Expanded = true;
        }

        private void CreateResources()
        {
            if (this.blueTex == null)
            {
                this.blueTex = new Texture2D(1, 1);
                this.blueTex.SetPixel(0, 0, new Color(0.23f, 0.35f, 0.55f));
                this.blueTex.Apply();
            }
            if (this.greyTex == null)
            {
                this.greyTex = new Texture2D(1, 1);
                this.greyTex.SetPixel(0, 0, new Color(0.3f, 0.3f, 0.3f));
                this.greyTex.Apply();
            }
            if (this.yellowTex == null)
            {
                this.yellowTex = new Texture2D(1, 1);
                this.yellowTex.SetPixel(0, 0, new Color(0.5f, 0.5f, 0.2f));
                this.yellowTex.Apply();
            }
            if (this.defaultIcon == null)
            {
                this.defaultIcon = EditorGUIUtility.LoadIcon("vcs_document");
            }
        }

        private string DisplayName(VCListItem item)
        {
            string name = item.Name;
            if ((name == string.Empty) && (item.Change != null))
            {
                name = item.Change.revision.ToString() + " " + item.Change.description;
            }
            return name;
        }

        private void DrawItem(VCListItem item, Rect area, float x, float y, bool focus, bool selected)
        {
            bool flag = item == this.dragTarget;
            bool flag2 = selected;
            if (selected)
            {
                Texture2D image = !focus ? this.greyTex : this.blueTex;
                GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), image, ScaleMode.StretchToFill, false);
            }
            else if (!flag)
            {
                if (((this.dragTarget != null) && (item == this.dragTarget.Parent)) && (this.dragAdjust != SelectDirection.Current))
                {
                    GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), this.yellowTex, ScaleMode.StretchToFill, false);
                    flag2 = true;
                }
            }
            else
            {
                SelectDirection dragAdjust = this.dragAdjust;
                if (dragAdjust == SelectDirection.Up)
                {
                    if (item.PrevOpenVisible != item.Parent)
                    {
                        GUI.DrawTexture(new Rect(x, y - 1f, area.width, 2f), this.yellowTex, ScaleMode.StretchToFill, false);
                    }
                }
                else if (dragAdjust == SelectDirection.Down)
                {
                    GUI.DrawTexture(new Rect(x, (y + 16f) - 1f, area.width, 2f), this.yellowTex, ScaleMode.StretchToFill, false);
                }
                else if (item.CanAccept)
                {
                    GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), this.yellowTex, ScaleMode.StretchToFill, false);
                    flag2 = true;
                }
            }
            if (item.CanExpand)
            {
                EditorGUI.Foldout(new Rect(x, y, 16f, 16f), item.Expanded, GUIContent.none);
            }
            Texture icon = item.Icon;
            Color color = GUI.color;
            Color contentColor = GUI.contentColor;
            if (item.Dummy)
            {
                GUI.color = new Color(0.65f, 0.65f, 0.65f);
            }
            if (!item.Dummy)
            {
                if (icon == null)
                {
                    icon = this.defaultIcon;
                }
                Rect position = new Rect(x + 14f, y, 16f, 16f);
                if (icon != null)
                {
                    GUI.DrawTexture(position, icon);
                }
                if (item.Asset != null)
                {
                    VCOverlay.DrawOverlay(item.Asset, position);
                }
            }
            if (flag2)
            {
                GUI.contentColor = new Color(3f, 3f, 3f);
                GUI.Label(new Rect(x + 32f, y, area.width - (x + 32f), 18f), this.DisplayName(item));
            }
            else
            {
                GUI.Label(new Rect(x + 32f, y, area.width - (x + 32f), 18f), this.DisplayName(item));
            }
            GUI.contentColor = contentColor;
            GUI.color = color;
        }

        ~VCListControl()
        {
            s_uniqueIDList.Remove(this.uniqueID);
        }

        public static VCListControl FromID(int id)
        {
            try
            {
                return s_uniqueIDList[id];
            }
            catch
            {
                return null;
            }
        }

        private VCListItem GetItemAt(Rect area, Vector2 pos)
        {
            int num = (int) ((pos.y - area.y) / 16f);
            if ((num >= 0) && (num < this.visibleList.Count))
            {
                return this.visibleList[num];
            }
            return null;
        }

        private void HandleKeyInput(Event e)
        {
            if ((e.type == EventType.KeyDown) && (this.selectList.Count != 0))
            {
                if ((e.keyCode == KeyCode.UpArrow) || (e.keyCode == KeyCode.DownArrow))
                {
                    VCListItem prevOpenSkip = null;
                    if (e.keyCode == KeyCode.UpArrow)
                    {
                        prevOpenSkip = this.SelectedFirstIn(this.active);
                        if (prevOpenSkip != null)
                        {
                            prevOpenSkip = prevOpenSkip.PrevOpenSkip;
                        }
                    }
                    else
                    {
                        prevOpenSkip = this.SelectedLastIn(this.active);
                        if (prevOpenSkip != null)
                        {
                            prevOpenSkip = prevOpenSkip.NextOpenSkip;
                        }
                    }
                    if (prevOpenSkip != null)
                    {
                        if (!this.ScrollUpTo(prevOpenSkip))
                        {
                            this.ScrollDownTo(prevOpenSkip);
                        }
                        if (e.shift)
                        {
                            this.SelectionFlow(prevOpenSkip);
                        }
                        else
                        {
                            this.SelectedSet(prevOpenSkip);
                        }
                    }
                }
                if ((e.keyCode == KeyCode.LeftArrow) || (e.keyCode == KeyCode.RightArrow))
                {
                    VCListItem item = this.SelectedCurrentIn(this.active);
                    item.Expanded = e.keyCode == KeyCode.RightArrow;
                    this.CallExpandedEvent(item, true);
                }
                if ((e.keyCode == KeyCode.Return) && (GUIUtility.keyboardControl == 0))
                {
                    this.SelectedCurrentIn(this.active).Asset.Edit();
                }
            }
        }

        private bool IsSelected(VCListItem item)
        {
            if (item.Asset != null)
            {
                return this.selectList.ContainsKey(item.Asset.path.ToLower());
            }
            return ((item.Change != null) && this.selectList.ContainsKey(item.Change.revision.ToString().ToLower()));
        }

        private bool IsSelectedFolder()
        {
            foreach (KeyValuePair<string, VCListItem> pair in this.selectList)
            {
                if ((pair.Value.Asset != null) && !pair.Value.Asset.isFolder)
                {
                    return false;
                }
            }
            return true;
        }

        private void LoadExpanded(VCListItem item)
        {
            if (item.Change != null)
            {
                item.Expanded = this.listState.Expanded.Contains(item.Change.revision);
            }
            for (VCListItem item2 = item.FirstChild; item2 != null; item2 = item2.Next)
            {
                this.LoadExpanded(item2);
            }
        }

        public bool OnGUI(Rect area, bool focus)
        {
            bool flag = false;
            this.CreateResources();
            Event current = Event.current;
            int openCount = this.active.OpenCount;
            int num2 = (int) (area.height / 16f);
            if (current.type == EventType.ScrollWheel)
            {
                flag = true;
                ListState listState = this.listState;
                listState.Scroll += current.delta.y;
                this.listState.Scroll = Mathf.Clamp(this.listState.Scroll, 0f, (float) (openCount - num2));
            }
            if (openCount > num2)
            {
                Rect position = new Rect((area.x + area.width) - 14f, area.y, 14f, area.height);
                area.width -= 14f;
                float scroll = this.listState.Scroll;
                this.listState.Scroll = GUI.VerticalScrollbar(position, this.listState.Scroll, (float) num2, 0f, (float) openCount);
                this.listState.Scroll = Mathf.Clamp(this.listState.Scroll, 0f, (float) (openCount - num2));
                if (scroll != this.listState.Scroll)
                {
                    flag = true;
                }
                if (!this.scrollVisible)
                {
                    GUIUtility.hotControl = 0;
                    this.scrollVisible = true;
                }
            }
            else if (this.scrollVisible)
            {
                GUIUtility.hotControl = 0;
                this.scrollVisible = false;
            }
            this.UpdateVisibleList(area, this.listState.Scroll);
            if (focus && !this.readOnly)
            {
                if (current.isKey)
                {
                    flag = true;
                    this.HandleKeyInput(current);
                }
                if ((current.type == EventType.MouseDown) && area.Contains(current.mousePosition))
                {
                    flag = true;
                    this.dragCount = 0;
                    GUIUtility.keyboardControl = 0;
                    this.singleSelect = this.GetItemAt(area, current.mousePosition);
                    if ((this.singleSelect != null) && !this.singleSelect.Dummy)
                    {
                        if (((current.button == 0) && (current.clickCount > 1)) && (this.singleSelect.Asset != null))
                        {
                            this.singleSelect.Asset.Edit();
                        }
                        if (current.button < 2)
                        {
                            float num4 = area.x + ((this.singleSelect.Indent - 1) * 0x12);
                            if (((current.mousePosition.x >= num4) && (current.mousePosition.x < (num4 + 16f))) && this.singleSelect.CanExpand)
                            {
                                this.singleSelect.Expanded = !this.singleSelect.Expanded;
                                this.CallExpandedEvent(this.singleSelect, true);
                                this.singleSelect = null;
                            }
                        }
                        if ((current.button == 0) && (this.singleSelect != null))
                        {
                            if (current.control)
                            {
                                this.SelectedAdd(this.singleSelect);
                                this.singleSelect = null;
                            }
                            else if (current.shift)
                            {
                                this.SelectionFlow(this.singleSelect);
                                this.singleSelect = null;
                            }
                            else if (this.IsSelected(this.singleSelect))
                            {
                                this.singleSelect = null;
                            }
                        }
                    }
                    else if (current.button == 0)
                    {
                        this.SelectedClear();
                        this.singleSelect = null;
                    }
                    if (current.button == 1)
                    {
                        if ((this.singleSelect != null) && !this.IsSelected(this.singleSelect))
                        {
                            this.SelectedSet(this.singleSelect);
                        }
                        this.singleSelect = null;
                        if (this.IsSelectedFolder() && (this.menuFolder != null))
                        {
                            EditorUtility.DisplayPopupMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), this.menuFolder, new MenuCommand(null, this.uniqueID));
                        }
                        else if (this.menuDefault != null)
                        {
                            EditorUtility.DisplayPopupMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), this.menuDefault, new MenuCommand(null, this.uniqueID));
                        }
                    }
                }
                if (current.type == EventType.MouseUp)
                {
                    this.dragCount = 0;
                    flag = true;
                    if (this.singleSelect != null)
                    {
                        this.SelectedSet(this.singleSelect);
                        this.singleSelect = null;
                    }
                }
                if ((current.type == EventType.MouseDrag) && area.Contains(current.mousePosition))
                {
                    this.dragCount++;
                    if ((this.dragCount > 2) && (Selection.objects.Length > 0))
                    {
                        DragAndDrop.PrepareStartDrag();
                        if (this.singleSelect != null)
                        {
                            DragAndDrop.objectReferences = new UnityEngine.Object[] { this.singleSelect.Asset.Load() };
                        }
                        else
                        {
                            DragAndDrop.objectReferences = Selection.objects;
                        }
                        DragAndDrop.StartDrag("Move");
                    }
                }
                if (current.type == EventType.DragUpdated)
                {
                    flag = true;
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                    this.dragTarget = this.GetItemAt(area, current.mousePosition);
                    if (this.dragTarget != null)
                    {
                        if (this.IsSelected(this.dragTarget))
                        {
                            this.dragTarget = null;
                        }
                        else if (this.dragAcceptOnly)
                        {
                            if (!this.dragTarget.CanAccept)
                            {
                                this.dragTarget = null;
                            }
                        }
                        else
                        {
                            bool flag2 = !this.dragTarget.CanAccept || (this.dragTarget.PrevOpenVisible != this.dragTarget.Parent);
                            bool flag3 = !this.dragTarget.CanAccept || (this.dragTarget.NextOpenVisible != this.dragTarget.FirstChild);
                            float num5 = !this.dragTarget.CanAccept ? 8f : 2f;
                            int num6 = (int) ((current.mousePosition.y - area.y) / 16f);
                            float num7 = area.y + (num6 * 16f);
                            this.dragAdjust = SelectDirection.Current;
                            if (flag2 && (current.mousePosition.y <= (num7 + num5)))
                            {
                                this.dragAdjust = SelectDirection.Up;
                            }
                            else if (flag3 && (current.mousePosition.y >= ((num7 + 16f) - num5)))
                            {
                                this.dragAdjust = SelectDirection.Down;
                            }
                        }
                    }
                    if (current.mousePosition.y < (area.y + 16f))
                    {
                        this.listState.Scroll = Mathf.Clamp(this.listState.Scroll - 1f, 0f, (float) (openCount - num2));
                    }
                    else if (current.mousePosition.y > ((area.y + area.height) - 16f))
                    {
                        this.listState.Scroll = Mathf.Clamp(this.listState.Scroll + 1f, 0f, (float) (openCount - num2));
                    }
                }
                if (current.type == EventType.DragPerform)
                {
                    if (this.singleSelect != null)
                    {
                        this.SelectedSet(this.singleSelect);
                        this.singleSelect = null;
                    }
                    if (this.dragTarget != null)
                    {
                        VCListItem item = (this.dragAdjust != SelectDirection.Current) ? this.dragTarget.Parent : this.dragTarget;
                        if (((this.dragDelegate != null) && (item != null)) && item.CanAccept)
                        {
                            this.dragDelegate(item.Change);
                        }
                        this.dragTarget = null;
                    }
                }
                if (current.type == EventType.DragExited)
                {
                    this.dragTarget = null;
                }
            }
            float y = area.y;
            foreach (VCListItem item2 in this.visibleList)
            {
                float x = area.x + ((item2.Indent - 1) * 0x12);
                bool selected = ((!this.readOnly ? this.IsSelected(item2) : false) && (this.singleSelect == null)) || (item2 == this.singleSelect);
                this.DrawItem(item2, area, x, y, focus, selected);
                y += 16f;
            }
            return flag;
        }

        private VCListItem PathSearchFind(string path)
        {
            try
            {
                return this.pathSearch[path.ToLower()];
            }
            catch
            {
                return null;
            }
        }

        private void PathSearchUpdate(VCListItem item)
        {
            if (item.Asset.path.Length > 0)
            {
                this.pathSearch.Add(item.Asset.path.ToLower(), item);
            }
            for (VCListItem item2 = item.FirstChild; item2 != null; item2 = item2.Next)
            {
                this.PathSearchUpdate(item2);
            }
        }

        public void Refresh()
        {
            this.Refresh(true);
        }

        public void Refresh(bool updateExpanded)
        {
            if (updateExpanded)
            {
                this.LoadExpanded(this.root);
                this.root.Name = "ROOT";
                this.root.Expanded = true;
                this.listState.Expanded.Clear();
                this.CallExpandedEvent(this.root, false);
            }
            this.SelectedRefresh();
        }

        private bool ScrollDownTo(VCListItem item)
        {
            int scroll = (int) this.listState.Scroll;
            for (VCListItem item2 = (this.visibleList.Count <= 0) ? null : this.visibleList[this.visibleList.Count - 1]; (item2 != null) && (scroll >= 0); item2 = item2.NextOpenVisible)
            {
                if (item2 == item)
                {
                    this.listState.Scroll = scroll;
                    return true;
                }
                scroll++;
            }
            return false;
        }

        private bool ScrollUpTo(VCListItem item)
        {
            int scroll = (int) this.listState.Scroll;
            for (VCListItem item2 = (this.visibleList.Count <= 0) ? null : this.visibleList[0]; (item2 != null) && (scroll >= 0); item2 = item2.PrevOpenVisible)
            {
                if (item2 == item)
                {
                    this.listState.Scroll = scroll;
                    return true;
                }
                scroll--;
            }
            return false;
        }

        private void SelectedAdd(VCListItem item)
        {
            if (!item.Dummy)
            {
                VCListItem item2 = this.SelectedCurrentIn(this.active);
                if (item.Exclusive || ((item2 != null) && item2.Exclusive))
                {
                    this.SelectedSet(item);
                }
                else
                {
                    UnityEngine.Object[] objects = Selection.objects;
                    int index = 0;
                    if (objects != null)
                    {
                        index = objects.Length;
                    }
                    UnityEngine.Object[] destinationArray = new UnityEngine.Object[index + 1];
                    destinationArray[index] = item.Asset.Load();
                    this.selectList.Add(item.Asset.path.ToLower(), item);
                    if (index > 0)
                    {
                        Array.Copy(objects, destinationArray, index);
                    }
                    Selection.objects = destinationArray;
                }
            }
        }

        private void SelectedClear()
        {
            this.selectList.Clear();
            Selection.activeObject = null;
        }

        private VCListItem SelectedCurrentIn(VCListItem root)
        {
            foreach (KeyValuePair<string, VCListItem> pair in this.selectList)
            {
                if (pair.Value.IsChildOf(root))
                {
                    return pair.Value;
                }
            }
            return null;
        }

        private VCListItem SelectedFirstIn(VCListItem root)
        {
            VCListItem item = this.SelectedCurrentIn(root);
            for (VCListItem item2 = item; item2 != null; item2 = item2.PrevOpenVisible)
            {
                if (this.IsSelected(item2))
                {
                    item = item2;
                }
            }
            return item;
        }

        private VCListItem SelectedLastIn(VCListItem root)
        {
            VCListItem item = this.SelectedCurrentIn(root);
            for (VCListItem item2 = item; item2 != null; item2 = item2.NextOpenVisible)
            {
                if (this.IsSelected(item2))
                {
                    item = item2;
                }
            }
            return item;
        }

        private void SelectedRefresh()
        {
            Dictionary<string, VCListItem> dictionary = new Dictionary<string, VCListItem>();
            foreach (KeyValuePair<string, VCListItem> pair in this.selectList)
            {
                dictionary[pair.Key] = this.PathSearchFind(pair.Key);
            }
            this.selectList = dictionary;
        }

        private void SelectedSet(VCListItem item)
        {
            if (!item.Dummy)
            {
                this.selectList.Clear();
                if (item.Asset != null)
                {
                    this.selectList.Add(item.Asset.path.ToLower(), item);
                    Selection.activeObject = item.Asset.Load();
                }
                else if (item.Change != null)
                {
                    this.selectList.Add(item.Change.revision.ToString(), item);
                }
            }
        }

        private void SelectionFlow(VCListItem item)
        {
            if (this.selectList.Count == 0)
            {
                this.SelectedSet(item);
            }
            else if (!this.SelectionFlowDown(item))
            {
                this.SelectionFlowUp(item);
            }
        }

        private bool SelectionFlowDown(VCListItem item)
        {
            VCListItem item2;
            VCListItem item3 = item;
            for (item2 = item; item2 != null; item2 = item2.NextOpenVisible)
            {
                if (this.IsSelected(item2))
                {
                    item3 = item2;
                }
            }
            if (item == item3)
            {
                return false;
            }
            this.SelectedClear();
            this.SelectedAdd(item3);
            for (item2 = item; item2 != item3; item2 = item2.NextOpenVisible)
            {
                this.SelectedAdd(item2);
            }
            return true;
        }

        private bool SelectionFlowUp(VCListItem item)
        {
            VCListItem item2;
            VCListItem item3 = item;
            for (item2 = item; item2 != null; item2 = item2.PrevOpenVisible)
            {
                if (this.IsSelected(item2))
                {
                    item3 = item2;
                }
            }
            if (item == item3)
            {
                return false;
            }
            this.SelectedClear();
            this.SelectedAdd(item3);
            for (item2 = item; item2 != item3; item2 = item2.PrevOpenVisible)
            {
                this.SelectedAdd(item2);
            }
            return true;
        }

        public void Sync()
        {
            this.SelectedClear();
            foreach (UnityEngine.Object obj2 in Selection.objects)
            {
                if (AssetDatabase.IsMainAsset(obj2))
                {
                    string path = VCPath.Project + AssetDatabase.GetAssetOrScenePath(obj2);
                    VCListItem item = this.PathSearchFind(path);
                    if (item != null)
                    {
                        this.SelectedAdd(item);
                    }
                }
            }
        }

        private void UpdateVisibleList(Rect area, float scrollPos)
        {
            float y = area.y;
            float num2 = (area.y + area.height) - 16f;
            VCListItem nextOpenVisible = this.active.NextOpenVisible;
            this.visibleList.Clear();
            for (float i = 0f; i < scrollPos; i++)
            {
                if (nextOpenVisible == null)
                {
                    return;
                }
                nextOpenVisible = nextOpenVisible.NextOpenVisible;
            }
            for (VCListItem item2 = nextOpenVisible; (item2 != null) && (y < num2); item2 = item2.NextOpenVisible)
            {
                this.visibleList.Add(item2);
                y += 16f;
            }
        }

        public bool DragAcceptOnly
        {
            get
            {
                return this.dragAcceptOnly;
            }
            set
            {
                this.dragAcceptOnly = value;
            }
        }

        public DragDelegate DragEvent
        {
            get
            {
                return this.dragDelegate;
            }
            set
            {
                this.dragDelegate = value;
            }
        }

        public ExpandDelegate ExpandEvent
        {
            get
            {
                return this.expandDelegate;
            }
            set
            {
                this.expandDelegate = value;
            }
        }

        public ListState listState
        {
            get
            {
                if (this.m_listState == null)
                {
                    this.m_listState = new ListState();
                }
                return this.m_listState;
            }
        }

        public string MenuDefault
        {
            get
            {
                return this.menuDefault;
            }
            set
            {
                this.menuDefault = value;
            }
        }

        public string MenuFolder
        {
            get
            {
                return this.menuFolder;
            }
            set
            {
                this.menuFolder = value;
            }
        }

        public bool ReadOnly
        {
            get
            {
                return this.readOnly;
            }
            set
            {
                this.readOnly = value;
            }
        }

        public VCListItem Root
        {
            get
            {
                return this.root;
            }
        }

        public VCAssetList SelectedAssets
        {
            get
            {
                VCAssetList list = new VCAssetList();
                foreach (KeyValuePair<string, VCListItem> pair in this.selectList)
                {
                    if (pair.Value.Item is VCAsset)
                    {
                        list.Add(pair.Value.Item as VCAsset);
                    }
                }
                return list;
            }
        }

        public VCChanges SelectedChanges
        {
            get
            {
                VCChanges changes = new VCChanges();
                foreach (KeyValuePair<string, VCListItem> pair in this.selectList)
                {
                    if (pair.Value.Item is VCChangelist)
                    {
                        changes.Add(pair.Value.Item as VCChangelist);
                    }
                }
                return changes;
            }
        }

        public int Size
        {
            get
            {
                return this.visibleList.Count;
            }
        }

        public delegate void DragDelegate(VCChangelist target);

        public delegate void ExpandDelegate(VCChangelist expand, VCListItem item);

        [Serializable]
        public class ListState
        {
            [SerializeField]
            public List<string> Expanded = new List<string>();
            [SerializeField]
            public float Scroll;
        }

        public enum SelectDirection
        {
            Up,
            Down,
            Current
        }
    }
}

